import gtk
#import gnomeapplet
import gobject
#import logging
import time
from datetime import datetime, date, timedelta
import locale

#locale.setlocale(locale.LC_ALL, 'en_US.utf-8')

if(locale.nl_langinfo(locale.D_FMT)[0:2] != '%d'):
	ANOTHER_DAY_FMT = "%b. %d"
else:
	ANOTHER_DAY_FMT = "%d. %b."
	
	
tt = gtk.Window()
tt.set_name('gtk-tooltip')
tt.ensure_style()
tt_style = tt.get_style().copy()
tt.hide()
tt.unrealize()
		
class DateWidget (gtk.EventBox):
	"""
	
	"""
	def __init__(self, date):
		
		gtk.EventBox.__init__(self)
		
		widget = gtk.VBox()
		widget.set_border_width(2)
		
		"""header holds the day, and the date"""
		header = gtk.HBox()
		
		day = gtk.Label('day')
		day.set_alignment(0,0.5)

		d_time = gtk.Label()
		
		dateW = gtk.Label('date')
		dateW.set_alignment(1,0.5)
		header.pack_start(day,True,True,2)
		#header.pack_start(d_time)
		header.pack_start(dateW)
		widget.pack_start(header)

		hbox13 = gtk.HBox(False)
		"""Container holds the events in this widget"""
		container = gtk.VBox()
		self.container = container
		#abstand vom rand
		hbox13.pack_start(gtk.Label(),False,False,5)
		hbox13.pack_start(container,True,True)
		widget.pack_start(hbox13)

		day.set_markup('<span size="larger">%s</span>' % (date.strftime("%A")))
		dateW.set_markup('<span size="smaller">%s</span>' % (date.strftime(ANOTHER_DAY_FMT)))

		self.add(widget)
		day.modify_fg(self.state, self.style.black)
		dateW.modify_fg(self.state, self.style.black)

		self.show_all()
		
		if(date == datetime.today().date()):
			self.set_style(tt_style)

		pass

	def addEvent(self,event_widget):
		self.container.pack_start(event_widget,False,False)
		pass
